package com.bwsoft.api.action;

import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.Map;
import java.util.UUID;

import net.sf.json.JSONObject;

import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;

import com.bwsoft.api.pojo.ResponsePojo;
import com.bwsoft.util.StringUtils;
import com.bwsoft.util.ValidatorUtil;

public class UserAction extends ApiBaseAction<UserAction> {
	private static Logger LOG = Logger.getLogger(UserAction.class);

	private Integer category;
	
	private String userid;
	private String account;
	private Integer accountType;
	private String phone;
	private String nickname;
	private String code;
	private String password;
	private String compName;
	private Integer compNature;
	private String linkMan;
	private String fax;
	private String address;
	private String email;
	private String cnasFlag;
	private String birthday;
	private String sex;
	
	private String phoneOS;
	private String phoneModel;
	private String registrationID;
	
	/**
	 * 2.1.2.1 个人账户注册
	 * user_personRegister.action?accountType=5&phone=18516858763&code=1234&password=cuibowen
	 * @return
	 * @throws Exception 
	 * @throws IOException 
	 */
	@SuppressWarnings({ "unchecked"})
	public void personRegister() throws IOException, Exception {

		LOG.info("=================================开始调用【2.1.2.1 个人账户注册 personRegister】==============================");
		
		//得到调用接口开始时的毫秒数
		beginTimestamp=Calendar.getInstance().getTimeInMillis();
		Boolean canFlag=true;
		
		LOG.info("传入加密参数r="+r);
		if(r==null||r.trim().equals("")){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "r值不能为空");
			finishMethod();
			LOG.info("=======================================传入参数r为空，提前结束");
		}
		Map<String, Object> parameMap= reflexParameters();
		
		if(!parameMap.isEmpty()&&parameMap.containsKey("accountType")) this.setAccountType(Integer.parseInt((String) parameMap.get("accountType")));
		if(!parameMap.isEmpty()&&parameMap.containsKey("phone")) setPhone((String) (parameMap.get("phone")));
		if(!parameMap.isEmpty()&&parameMap.containsKey("code")) setCode((String) (parameMap.get("code")));
		if(!parameMap.isEmpty()&&parameMap.containsKey("password")) setPassword((String) (parameMap.get("password")));
		
		
		
		//传入参数
		//LOG.info("传入参数：accountType【"+accountType+"】phone【"+phone+"】code【"+code+"】password【"+password+"】");
		if(null==accountType||phone.isEmpty()||code.isEmpty()||password.isEmpty()){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "传入参数不能为空");
			canFlag=false;
		}
		//验证参数
		if(canFlag&&accountType!=3&&accountType!=4){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "个人账户注册accountType只能为3或者4");
			canFlag=false;
		}
		if(canFlag&&!ValidatorUtil.isMobile(phone)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "请输入正确的手机号！");
			canFlag=false;
		}
		if(canFlag&&code.isEmpty()){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "请输入验证码！");
			canFlag=false;
		}
		if(canFlag&&!ValidatorUtil.isPassword(password)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "密码格式有误！");
			canFlag=false;
		}
		
		
		if (canFlag) {
			// 调用service方法得到要返回的数据对象
			LOG.info("开始调用取数方法");
			ResponsePojo rp = userService.personRegister(accountType,phone,code,password);
			LOG.info("调用取数方法结束");
			responseJson.put("errcode", rp.getErrcode());
			responseJson.put("errmsg", rp.getErrmsg());
			responseJson.put("data", rp.getData());
		}
		
		finishMethod();
		LOG.info("=================================调用结束【2.1.2.1 个人账户注册 personRegister】==============================");
	}
	
	
	/**
	 * 2.1.2.2 实验室账户注册
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings({ "unchecked"})
	public void libRegister() throws Exception {

		LOG.info("=================================开始调用【2.1.2.2 实验室账户注册 libRegister】==============================");
		
		//得到调用接口开始时的毫秒数
		beginTimestamp=Calendar.getInstance().getTimeInMillis();
		Boolean canFlag=true;
		
		
       
		phone=phone.indexOf(',')>0? phone.substring(0, phone.indexOf(',')):phone;
		
		//传入参数
		LOG.info("传入参数：accountType【"+accountType+"】compName【"+compName+"】compNature【"+compNature+"】" +
				"linkMan【"+linkMan+"】phone【"+phone+"】address【"+address+"】email【"+email+"】password【"+password+"】" +
						"fax【"+fax+"】cnasFlag【"+cnasFlag+"】");
		
		if(null==accountType||compName.isEmpty()||null==compNature||linkMan.isEmpty()
				||phone.isEmpty()||address.isEmpty()||email.isEmpty()||password.isEmpty()){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "传入参数不能为空");
			canFlag=false;
		}
		//验证参数
		if(canFlag&&accountType!=1&&accountType!=2){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "实验室账户注册accountType只能为1或者2");
			canFlag=false;
		}
		if(canFlag&&!ValidatorUtil.isMobile(phone)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "请输入正确的手机号！");
			canFlag=false;
		}
		if(canFlag&&!ValidatorUtil.isEmail(email)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "请输入正确的邮箱！");
			canFlag=false;
		}
		if(canFlag&&!ValidatorUtil.isPassword(password)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "密码格式有误！");
			canFlag=false;
		}
		if(canFlag&&!userService.isImage(imgContentType)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "上传的文件不是图片类型！");
			canFlag=false;
		}
		if(canFlag&&!userService.isFitSize(img)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "上传的图片不能超过8M！");
			canFlag=false;
		}
		
		if (canFlag) {
			// 调用service方法得到要返回的数据对象
			LOG.info("开始调用取数方法");
			ResponsePojo rp = userService.libRegister(accountType,compName,compNature,linkMan,phone,address,email,password,fax,"1".equals(cnasFlag),img,imgFileName);
			LOG.info("调用取数方法结束");
			responseJson.put("errcode", rp.getErrcode());
			responseJson.put("errmsg", rp.getErrmsg());
			responseJson.put("data", rp.getData());
		}
		
		finishMethod();
		LOG.info("=================================调用结束【2.1.2.2 实验室账户注册 libRegister】==============================");
	}
	
	
	
	/**
	 * 2.1.2.2 实验室账户注册
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings({ "unchecked"})
	public void libRegisterAndroid() throws Exception {

		LOG.info("=================================开始调用【2.1.2.2 实验室账户注册 libRegister】==============================");
		
		//得到调用接口开始时的毫秒数
		beginTimestamp=Calendar.getInstance().getTimeInMillis();
		Boolean canFlag=true;
		
		
       
		phone=phone.indexOf(',')>0? phone.substring(0, phone.indexOf(',')):phone;
		
		//传入参数
		LOG.info("传入参数：accountType【"+accountType+"】compName【"+compName+"】compNature【"+compNature+"】" +
				"linkMan【"+linkMan+"】phone【"+phone+"】address【"+address+"】email【"+email+"】password【"+password+"】" +
						"fax【"+fax+"】cnasFlag【"+cnasFlag+"】");
		
		if(null==accountType||compName.isEmpty()||null==compNature||linkMan.isEmpty()
				||phone.isEmpty()||address.isEmpty()||email.isEmpty()||password.isEmpty()){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "传入参数不能为空");
			canFlag=false;
		}
		//验证参数
		if(canFlag&&accountType!=1&&accountType!=2){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "实验室账户注册accountType只能为1或者2");
			canFlag=false;
		}
		if(canFlag&&!ValidatorUtil.isMobile(phone)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "请输入正确的手机号！");
			canFlag=false;
		}
		if(canFlag&&!ValidatorUtil.isEmail(email)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "请输入正确的邮箱！");
			canFlag=false;
		}
		if(canFlag&&!ValidatorUtil.isPassword(password)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "密码格式有误！");
			canFlag=false;
		}
/*		if(canFlag&&!userService.isImage(imgContentType)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "上传的文件不是图片类型！");
			canFlag=false;
		}
		if(canFlag&&!userService.isFitSize(img)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "上传的图片不能超过8M！");
			canFlag=false;
		}*/
		
		if (canFlag) {
			// 调用service方法得到要返回的数据对象
			LOG.info("开始调用取数方法");
			img = new File[2];
			img[0]=img1;
			img[1]=img2;
			imgFileName=new String[2];
			imgFileName[0]=img1FileName;
			imgFileName[1]=img2FileName;
			ResponsePojo rp = userService.libRegister(accountType,compName,compNature,linkMan,phone,address,email,password,fax,"1".equals(cnasFlag),img,imgFileName);
			LOG.info("调用取数方法结束");
			responseJson.put("errcode", rp.getErrcode());
			responseJson.put("errmsg", rp.getErrmsg());
			responseJson.put("data", rp.getData());
		}
		
		finishMethod();
		LOG.info("=================================调用结束【2.1.2.2 实验室账户注册 libRegister】==============================");
	}
	
	
	
	/**
	 * 2.1.1 登陆
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings({ "unchecked"})
	public void login() throws Exception {

		LOG.info("=================================开始调用【2.1.1 登陆 login】==============================");
		
		//得到调用接口开始时的毫秒数
		beginTimestamp=Calendar.getInstance().getTimeInMillis();
		Boolean canFlag=true;
		
		LOG.info("传入加密参数r="+r);
		if(r==null||r.trim().equals("")){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "r值不能为空");
			finishMethod();
			LOG.info("=======================================传入参数r为空，提前结束");
		}
		Map<String, Object> parameMap= reflexParameters();
		
		if(!parameMap.isEmpty()&&parameMap.containsKey("account")) this.setAccount((String) parameMap.get("account"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("password")) this.setPassword((String) (parameMap.get("password")));
       
		
		//传入参数
		//LOG.info("传入参数：account【"+account+"】password【"+password+"】");
		
		//验证参数
		if(canFlag&&!ValidatorUtil.isMobile(account)&&!ValidatorUtil.isEmail(account)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "账号只能为邮箱或手机号！");
			canFlag=false;
		}
		if(canFlag&&!ValidatorUtil.isPassword(password)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "密码格式有误！");
			canFlag=false;
		}

		if (canFlag) {
			// 调用service方法得到要返回的数据对象
			LOG.info("开始调用取数方法");
			ResponsePojo rp = userService.userLogin(account,password);
			LOG.info("调用取数方法结束");
			responseJson.put("errcode", rp.getErrcode());
			responseJson.put("errmsg", rp.getErrmsg());
			responseJson.put("data", rp.getData());
		}
		
		finishMethod();
		LOG.info("=================================调用结束【2.1.1 登陆 login】==============================");
	}
	
	/**
	 * 2.1.5 用户登录后回调系统接口
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings({ "unchecked"})
	public void returnLoginMsg() throws Exception {

		LOG.info("=================================开始调用【2.1.5 用户登录后回调系统接口】==============================");
		
		//得到调用接口开始时的毫秒数
		beginTimestamp=Calendar.getInstance().getTimeInMillis();
		Boolean canFlag=true;
		
		LOG.info("传入加密参数r="+r);
		if(r==null||r.trim().equals("")){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "r值不能为空");
			finishMethod();
			LOG.info("=======================================传入参数r为空，提前结束");
		}
		Map<String, Object> parameMap= reflexParameters();
		
		if(!parameMap.isEmpty()&&parameMap.containsKey("userid")) this.setUserid((String) parameMap.get("userid"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("phoneOS")) this.setPhoneOS((String) parameMap.get("phoneOS"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("phoneModel")) this.setPhoneModel((String) (parameMap.get("phoneModel")));
		if(!parameMap.isEmpty()&&parameMap.containsKey("registrationID")) this.setRegistrationID((String) (parameMap.get("registrationID")));
       
		
		if(null==userid||"".equals(userid.trim())){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "userid 不能为空！");
			canFlag=false;
		}
		if(null==registrationID||"".equals(registrationID.trim())){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "registrationID 不能为空！");
			canFlag=false;
		}

		if (canFlag) {
			// 调用service方法得到要返回的数据对象
			LOG.info("开始调用取数方法");
			ResponsePojo rp = userService.returnLoginMsg(userid,phoneOS,phoneModel,registrationID);
			LOG.info("调用取数方法结束");
			responseJson.put("errcode", rp.getErrcode());
			responseJson.put("errmsg", rp.getErrmsg());
			responseJson.put("data", rp.getData());
		}
		
		finishMethod();
		LOG.info("=================================调用结束【2.1.5 用户登录后回调系统接口】==============================");
	}
	
	/**
	 * 2.5.1 获取个人信息
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings({ "unchecked"})
	public void info() throws Exception {

		LOG.info("=================================开始调用【2.5.1获取个人信息 info】==============================");
		
		//得到调用接口开始时的毫秒数
		beginTimestamp=Calendar.getInstance().getTimeInMillis();
		Boolean canFlag=true;
		
		LOG.info("传入加密参数r="+r);
		if(r==null||r.trim().equals("")){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "r值不能为空");
			finishMethod();
			LOG.info("=======================================传入参数r为空，提前结束");
		}
		Map<String, Object> parameMap= reflexParameters();
		
		if(!parameMap.isEmpty()&&parameMap.containsKey("userid")) this.setUserid((String) parameMap.get("userid"));
       
		if(getUserid()==null||getUserid().equals("")){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "userid不能为空！");
			canFlag=false;
		}
		
		//传入参数
		//LOG.info("传入参数：userid【"+userid+"】");
		

		if (canFlag) {
			// 调用service方法得到要返回的数据对象
			LOG.info("开始调用取数方法");
			ResponsePojo rp = userService.userInfo(userid);
			LOG.info("调用取数方法结束");
			responseJson.put("errcode", rp.getErrcode());
			responseJson.put("errmsg", rp.getErrmsg());
			responseJson.put("data", rp.getData());
		}
		
		finishMethod();
		LOG.info("=================================调用结束【2.5.1获取个人信息 info】==============================");
	}
	
	
	/**
	 * 2.5.2.2 手机号修改密码
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings({ "unchecked"})
	public void changePwd() throws Exception {

		LOG.info("=================================开始调用【2.5.2.2 手机号修改密码 changePwdByPhone】==============================");
		
		//得到调用接口开始时的毫秒数
		beginTimestamp=Calendar.getInstance().getTimeInMillis();
		Boolean canFlag=true;
		
		LOG.info("传入加密参数r="+r);
		if(r==null||r.trim().equals("")){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "r值不能为空");
			finishMethod();
			LOG.info("=======================================传入参数r为空，提前结束");
		}
		Map<String, Object> parameMap= reflexParameters();
		
		if(!parameMap.isEmpty()&&parameMap.containsKey("account")) this.setAccount((String)parameMap.get("account"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("code")) this.setCode((String) parameMap.get("code"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("password")) this.setPassword((String) parameMap.get("password"));
       
		if(account==null||account.trim().equals("")||
				code==null||code.trim().equals("")||
						password==null||password.trim().equals("")){
			
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "参数不能为空！");
			canFlag=false;
			
		}
		
		
		//传入参数
		//LOG.info("传入参数：account【"+account+"】code【"+code+"】password【"+password+"】");
		
		

		if (canFlag) {
			// 调用service方法得到要返回的数据对象
			LOG.info("开始调用取数方法");
			ResponsePojo rp = userService.changePwd(account,code,password);
			LOG.info("调用取数方法结束");
			responseJson.put("errcode", rp.getErrcode());
			responseJson.put("errmsg", rp.getErrmsg());
			responseJson.put("data", rp.getData());
		}
		
		finishMethod();
		LOG.info("=================================调用结束【2.5.2.2 手机号修改密码 changePwdByPhone】==============================");
	}
	
	
	/**
	 * 2.5.4 修改个人信息
	 * @throws Exception 
	 * @throws IOException 
	 */
	@SuppressWarnings("unchecked")
	public void updatePersonInfo() throws IOException, Exception{
		
		LOG.info("=================================开始调用【2.5.4 修改个人信息 updateUserInfo】==============================");
		
		//得到调用接口开始时的毫秒数
		beginTimestamp=Calendar.getInstance().getTimeInMillis();
		Boolean canFlag=true;
		
		LOG.info("传入加密参数r="+r);
		if(r==null||r.trim().equals("")){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "r值不能为空");
			finishMethod();
			LOG.info("=======================================传入参数r为空，提前结束");
		}
		Map<String, Object> parameMap= reflexParameters();
		
		if(!parameMap.isEmpty()&&parameMap.containsKey("userid")) this.setUserid((String)parameMap.get("userid"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("nickname")) this.setNickname((String)parameMap.get("nickname"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("email")) this.setEmail((String)parameMap.get("email"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("compName")) this.setCompName((String)parameMap.get("compName"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("address")) this.setAddress((String)parameMap.get("address"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("birthday")) this.setBirthday((String)parameMap.get("birthday"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("sex")) this.setSex((String)parameMap.get("sex"));
       
		//传入参数
		//LOG.info("传入参数：userid【"+userid+"】nickname【"+nickname+"】email【"+email+"】" +
		//		"compName【"+compName+"】address【"+address+"】birthday【"+birthday+"】" +
		//		"sex【"+sex+"】");

		
		if (userid == null || userid.trim().equals("") || nickname == null
				|| nickname.trim().equals("") ) {
			
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "参数不能为空！");
			canFlag=false;
			
		}
		
		
		if(canFlag&&nickname.length()>20){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "昵称不能大于20位！");
			canFlag=false;
		}
		
		if(canFlag&&email!=null&&!email.trim().equals("")&&!ValidatorUtil.isEmail(email)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "请输入正确的邮箱！");
			canFlag=false;
		}
		

		if (canFlag) {
			// 调用service方法得到要返回的数据对象
			LOG.info("开始调用取数方法");
			ResponsePojo rp = userService.updatePersonInfo(userid,nickname,email,compName,address,birthday,sex);
			LOG.info("调用取数方法结束");
			responseJson.put("errcode", rp.getErrcode());
			responseJson.put("errmsg", rp.getErrmsg());
			responseJson.put("data", rp.getData());
		}
		
		finishMethod();
		LOG.info("=================================调用结束【2.5.4 修改个人信息 updateUserInfo】==============================");
		
	}
	
	
	/**
	 * 2.5.4 修改个人信息
	 * @throws Exception 
	 * @throws IOException 
	 */
	@SuppressWarnings("unchecked")
	public void updateLibInfo() throws IOException, Exception{
		
		LOG.info("=================================开始调用【2.5.5 修改个人信息 updateLibInfo】==============================");
		
		//得到调用接口开始时的毫秒数
		beginTimestamp=Calendar.getInstance().getTimeInMillis();
		Boolean canFlag=true;
		
		LOG.info("传入加密参数r="+r);
		if(r==null||r.trim().equals("")){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "r值不能为空");
			finishMethod();
			LOG.info("=======================================传入参数r为空，提前结束");
		}
		Map<String, Object> parameMap= reflexParameters();
		
		if(!parameMap.isEmpty()&&parameMap.containsKey("userid")) this.setUserid((String)parameMap.get("userid"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("nickname")) this.setNickname((String)parameMap.get("nickname"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("linkman")) this.setLinkMan((String)parameMap.get("linkman"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("phone")) this.setPhone((String)parameMap.get("phone"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("address")) this.setAddress((String)parameMap.get("address"));
		if(!parameMap.isEmpty()&&parameMap.containsKey("fax")) this.setFax((String)parameMap.get("fax"));
       
		
		if (userid == null || userid.trim().equals("") || nickname == null
				|| nickname.trim().equals("") ) {
			
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "参数不能为空！");
			canFlag=false;
			
		}
		
		
		if(canFlag&&nickname.length()>20){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "昵称不能大于20位字符！");
			canFlag=false;
		}
		
		if(canFlag&&phone!=null&&!phone.trim().equals("")&&!ValidatorUtil.isMobile(phone)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "请输入正确的手机号！");
			canFlag=false;
		}
		

		if (canFlag) {
			// 调用service方法得到要返回的数据对象
			LOG.info("开始调用取数方法");
			ResponsePojo rp = userService.updateLibInfo(userid,nickname,linkMan,phone,address,fax);
			LOG.info("调用取数方法结束");
			responseJson.put("errcode", rp.getErrcode());
			responseJson.put("errmsg", rp.getErrmsg());
			responseJson.put("data", rp.getData());
		}
		
		finishMethod();
		LOG.info("=================================调用结束【2.5.5 修改个人信息 updateLibInfo】==============================");
		
	}
	
	
	/**
	 * 2.5.6 修改头像
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings({ "unchecked"})
	public void updateHeadImage() throws Exception {

		LOG.info("=================================开始调用【2.5.6 修改头像 updateHeadImage】==============================");
		
		//得到调用接口开始时的毫秒数
		beginTimestamp=Calendar.getInstance().getTimeInMillis();
		Boolean canFlag=true;
		
       
		
		
		if(userid == null || userid.trim().equals("")){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "用户编号不能为空");
			canFlag=false;
		}
		
		if(canFlag&&img.length==0){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "请上传需要替换的头像！");
			canFlag=false;
		}
		
		if(canFlag&&!userService.isImage(imgContentType)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "上传的文件不是图片类型！");
			canFlag=false;
		}
		if(canFlag&&!userService.isFitSize(img)){
			responseJson.put("errcode", 1);
			responseJson.put("errmsg", "上传的图片不能超过8M！");
			canFlag=false;
		}
		
		if (canFlag) {
			// 调用service方法得到要返回的数据对象
			LOG.info("开始调用取数方法");
			ResponsePojo rp = userService.updateHeadImage(userid,img,imgFileName);
			LOG.info("调用取数方法结束");
			responseJson.put("errcode", rp.getErrcode());
			responseJson.put("errmsg", rp.getErrmsg());
			responseJson.put("data", rp.getData());
		}
		
		finishMethod();
		LOG.info("=================================调用结束【2.5.6 修改头像 updateHeadImage】==============================");
	}
	
	
	
	public Integer getCategory() {
		return category;
	}

	public void setCategory(Integer category) {
		this.category = category;
	}

	public Integer getAccountType() {
		return accountType;
	}

	public void setAccountType(Integer accountType) {
		this.accountType = accountType;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getCompName() {
		return compName;
	}

	public void setCompName(String compName) {
		this.compName = compName;
	}

	public Integer getCompNature() {
		return compNature;
	}

	public void setCompNature(Integer compNature) {
		this.compNature = compNature;
	}

	public String getLinkMan() {
		return linkMan;
	}

	public void setLinkMan(String linkMan) {
		this.linkMan = linkMan;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}



	public String getCnasFlag() {
		return cnasFlag;
	}


	public void setCnasFlag(String cnasFlag) {
		this.cnasFlag = cnasFlag;
	}


	public String getAccount() {
		return account;
	}


	public void setAccount(String account) {
		this.account = account;
	}


	public String getUserid() {
		return userid;
	}


	public void setUserid(String userid) {
		this.userid = userid;
	}


	public String getNickname() {
		return nickname;
	}


	public void setNickname(String nickname) {
		this.nickname = nickname;
	}


	public String getBirthday() {
		return birthday;
	}


	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}


	public String getSex() {
		return sex;
	}


	public void setSex(String sex) {
		this.sex = sex;
	}


	public String getPhoneOS() {
		return phoneOS;
	}


	public void setPhoneOS(String phoneOS) {
		this.phoneOS = phoneOS;
	}


	public String getPhoneModel() {
		return phoneModel;
	}


	public void setPhoneModel(String phoneModel) {
		this.phoneModel = phoneModel;
	}


	public String getRegistrationID() {
		return registrationID;
	}


	public void setRegistrationID(String registrationID) {
		this.registrationID = registrationID;
	}



	
}
